package com.isdepci.project.carbon.service.impl;

import com.isdepci.project.carbon.domain.CcerProject;
import com.isdepci.project.carbon.mapper.CcerProjectMapper;
import com.isdepci.project.carbon.service.ICcerProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * CCER项目Service业务层处理
 *
 * @author isdepci
 * @date 2023-05-15
 */
@Service
public class CcerProjectServiceImpl implements ICcerProjectService {
    @Autowired
    private CcerProjectMapper ccerProjectMapper;

    /**
     * 查询CCER项目
     */
    @Override
    public CcerProject selectProjectListById(Long id){
        return ccerProjectMapper.selectProjectListById(id);
    }

    @Override
    public List<CcerProject> selectCCERDict() {
        return ccerProjectMapper.selectCCERDict();
    }

    /**
     * 查询CCER项目列表
     */
    @Override
    public List<CcerProject> selectProjectListList(CcerProject ccerProject){
        return ccerProjectMapper.selectProjectListList(ccerProject);
    }

    /**
     * 新增CCER项目
     */
    @Override
    public int insertProjectList(CcerProject ccerProject){
        return ccerProjectMapper.insertProjectList(ccerProject);
    }

    /**
     * 修改CCER项目
     */
    @Override
    public int updateProjectList(CcerProject ccerProject){
        return ccerProjectMapper.updateProjectList(ccerProject);
    }

    /**
     * 批量删除CCER项目
     */
    @Override
    public int deleteProjectListByIds(Long[] ids){
        return ccerProjectMapper.deleteProjectListByIds(ids);
    }

    /**
     * 删除CCER项目信息
     */
    @Override
    public int deleteProjectListById(Long id){
        return ccerProjectMapper.deleteProjectListById(id);
    }


    /**
     * 查询CCER项目名称
     */
    @Override
    public List<CcerProject> selectProjectListNameList(CcerProject ccerProject) {
        //查询出数据列表
        List<CcerProject> ccerProjects = ccerProjectMapper.selectProjectListList(ccerProject);

        //从数据列表里获取CCER项目名称
        List<String> names = ccerProjects.stream().map(ccerProject1 -> ccerProject1.getProjectName()).collect(Collectors.toList());

        //放入集合返回
        List nameList=new ArrayList();
        nameList.add(names);
        return nameList;
    }
}
